document
		.write("<script src=\""
				+ context
				+ "/temp-store/jsstuff/tableview/bestboy.js\" type=\"text/javascript\"></script>");

(function($) {
	var methods = {
		checkItemInGroup : function(checkIds, id) {
			if (checkIds == null) {
				return false;
			}
			var ids = checkIds.split(",");
			return $.inArray(id, ids) > -1;
		},
		parseTime : function(obj, defaultTime) {
			var s = "";
			if (obj.indexOf("-") > -1) {
				f = obj.substring(0, obj.indexOf("-"));
				m = obj.substring(obj.indexOf("-") + 1, obj.lastIndexOf("-"));
				e = obj.substring(obj.lastIndexOf("-") + 1, obj
								.lastIndexOf("-")
								+ 3);
				s = f + m + e;
			}

			if (obj.indexOf(":") > -1) {
				hh = obj.substring(obj.indexOf(":") - 2, obj.indexOf(":"));
				mm = obj.substring(obj.indexOf(":") + 1);
				ss = "00";
				s += hh + mm + ss;

			} else if (defaultTime != null) {
				s += defaultTime;
			}

			return s;
		},
		parseDate : function(obj, defaultTime) {
			var s = "";
			if (obj.indexOf("-") > -1) {
				f = obj.substring(0, obj.indexOf("-"));
				m = obj.substring(obj.indexOf("-") + 1, obj.lastIndexOf("-"));
				e = obj.substring(obj.lastIndexOf("-") + 1);
				s = f + m + e;

				if (defaultTime != null) {
					s += defaultTime
				}
			}

			return s;
		},
		formatTime : function(obj, defaultTime) {
			var s = "";
			if (obj.length == 8) {
				f = obj.substring(0, 4);
				m = obj.substring(4, 6);
				e = obj.substring(6, 8);
				s = f + "-" + m + "-" + e;
			} else if (obj.length == 14) {
				f = obj.substring(0, 4);
				m = obj.substring(4, 6);
				e = obj.substring(6, 8);
				h = obj.substring(8, 10);
				mm = obj.substring(10, 12);
				ss = obj.substring(12, 14);
				s = f + "-" + m + "-" + e + " " + h + ":" + mm + ":" + ss;
			}

			return s;
		},
		formatDate : function(obj, defaultTime) {
			var s = "";
			if (obj.length >= 8) {
				f = obj.substring(0, 4);
				m = obj.substring(4, 6);
				e = obj.substring(6, 8);
				s = f + "-" + m + "-" + e;
			}

			return s;
		},
		getDefaultValue : function(obj, param) {

			var reg = new RegExp("^@");

			if (obj != null && reg.test(obj)) {
				return $.trim(param[obj.substring(1)]);
			}

			return "";
		},
		findForItem : function(items, forItem) {
			var s;
			$.each(items, function(i, m) {
						if (m.formName == forItem) {
							s = m;
							return false;
						}
					});
			return s;
		},
		assemblingItemPlug : function(ipt, paramObj) {
			if (paramObj.width != null) {
				ipt.width = paramObj.width;
			}

			if (paramObj.group != null) {
				ipt.group = paramObj.group;
			}

			if (paramObj.groupicon != null) {
				ipt.groupicon = paramObj.groupicon;
			}

			if (ipt.type == "textarea") {
				if (paramObj.cols != null) {
					ipt.cols = paramObj.cols;
				}

				if (paramObj.rows != null) {
					ipt.rows = paramObj.rows;
				}
			}

			if (paramObj.validate != null) {
				ipt.validate = paramObj.validate;
			}
		},
		assemblingItem : function(fields, component, vlu, validators, mode) {
			var paramObj = eval(component.param);
			var newline = (paramObj.newline == null ? false : paramObj.newline);

			// push validator component
			if (paramObj.validate != null) {
				validators.push(component.formName);
			}

			if (component.type == "input") {
				var ipt = {
					display : component.label,
					name : component.formName,
					id : component.formName,
					newline : newline,
					type : "text",
					options : {
						number : paramObj.number == true,
						digits : paramObj.digits == true,
						currency : paramObj.currency == true,
						value : (vlu == null ? component.defaultValue : vlu),
						readonly : (mode == "view" || paramObj.readOnly == true)
					}
				}

				this.assemblingItemPlug(ipt, paramObj);
				fields.push(ipt);
			} else if (component.type == "hidden") {
				var ipt = {
					name : component.formName,
					id : component.formName,
					newline : newline,
					type : "hidden",
					options : {
						value : (vlu == null ? component.defaultValue : vlu)
					}
				}

				fields.push(ipt);
			} else if (component.type == "textarea") {
				var ipt = {
					display : component.label,
					name : component.formName,
					id : component.formName,
					newline : newline,
					options : {
						value : (vlu == null ? component.defaultValue : vlu),
						readonly : (mode == "view" || paramObj.readOnly == true)
					},
					type : "textarea"
				}

				this.assemblingItemPlug(ipt, paramObj);

				fields.push(ipt);
			} else if (component.type == "date") {
				var ipt = {
					display : component.label,
					name : component.formName + "_",
					options : {
						value : (vlu == null ? methods
								.formatDate(component.defaultValue) : methods
								.formatDate(vlu)),
						onChange : function(val) {
							$("#" + component.formName).val(methods.parseDate(
									val, "000000"));
						},
						readonly : (mode == "view" || paramObj.readOnly == true)
					},
					type : "date",
					newline : newline,
					id : component.formName + "_"
				}

				this.assemblingItemPlug(ipt, paramObj);

				fields.push(ipt);

				var ipt1 = {
					name : component.formName,
					id : component.formName,
					options : {
						value : (vlu == null ? component.defaultValue : vlu)
					},
					type : "hidden"
				}

				fields.push(ipt1);
				/*
				 * ipt.change(function() { $("#" +
				 * component.formName).val(methods.formatTime( mainform.val(),
				 * "000000")); });
				 */

			} else if (component.type == "time") {
				var ipt = {
					display : component.label,
					name : component.formName + "_",
					format : "yyyy-MM-dd hh:mm:ss",
					options : {
						showTime : true,
						value : (vlu == null ? component.defaultValue : methods
								.formatDate(vlu)),
						onChange : function(val) {
							$("#" + component.formName).val(methods.parseTime(
									val, "000000"));
						},
						readonly : (mode == "view" || paramObj.readOnly == true)
					},
					type : "date",
					newline : newline,
					id : component.formName + "_"
				}

				this.assemblingItemPlug(ipt, paramObj);

				fields.push(ipt);

				var ipt1 = {
					name : component.formName,
					id : component.formName,
					options : {
						value : (vlu == null ? component.defaultValue : vlu)
					},
					type : "hidden"
				}

				fields.push(ipt1);
				/*
				 * ipt.change(function() { $("#" +
				 * component.formName).val(methods.formatTime( mainform.val(),
				 * "000000")); });
				 */

			} else if (component.type == "select"
					|| component.type == "combobox") {
				if ((mode == "view" || paramObj.readOnly == true)) {
					var ipt = {
						display : component.label,
						name : component.formName,
						id : component.formName,
						newline : newline,
						type : "text",
						options : {
							value : (vlu == null ? component.defaultValue : vlu),
							readonly : (mode == "view" || paramObj.readOnly == true)
						}
					}

					this.assemblingItemPlug(ipt, paramObj);

					fields.push(ipt);
				} else {
					var values = paramObj.items;
					var dataGrid = [];

					for (var i = 0; i < values.length; i++) {
						var dataObj = {};
						dataObj["id"] = values[i].id;
						dataObj[component.formName + "_name"] = values[i].name;
						dataGrid.push(dataObj);

					}

					var selector = {
						display : component.label,
						name : component.formName,
						id : component.formName,
						type : "select",
						comboboxName : (component.formName + "_name"),
						newline : newline,

						options : {
							valueField : "id",
							textField : (component.formName + "_name"),
							data : dataGrid,
							valueFieldID : paramObj.forItem,
							onSelected : function(val, txt) {
								$("#" + paramObj.forItem).val(txt);
							}
						}
					};

					this.assemblingItemPlug(selector, paramObj);

					if (vlu != null) {
						selector.options.initValue = vlu;
					} else if (paramObj.checkItem != null) {
						selector.options.initValue = paramObj.checkItem;
					}

					fields.push(selector);
				}
			} else if (component.type == "checkbox") {
				if (paramObj != null && paramObj.items != null) {
					if ((mode == "view" || paramObj.readOnly == true)) {
						var ipt = {
							display : component.label,
							name : component.formName,
							id : component.formName,
							newline : newline,
							type : "text",
							options : {
								value : (vlu == null
										? component.defaultValue
										: vlu),
								readonly : (mode == "view" || paramObj.readOnly == true)
							}
						}

						this.assemblingItemPlug(ipt, paramObj);

						fields.push(ipt);
					} else {

						var values = paramObj.items;
						var dataGrid = [];

						for (var i = 0; i < values.length; i++) {
							var dataObj = {};
							dataObj["id"] = values[i].id;
							dataObj[component.formName + "_name"] = values[i].name;
							dataGrid.push(dataObj);

						}

						var selector = {
							display : component.label,
							name : component.formName,
							id : component.formName,
							type : "select",
							comboboxName : (component.formName + "_name"),
							newline : newline,

							options : {
								valueField : "id",
								textField : (component.formName + "_name"),
								data : dataGrid,
								split : ",",
								isMultiSelect : true, // 是否多选
								isShowCheckBox : true, // 是否选择复选框
								valueFieldID : paramObj.forItem,
								onSelected : function(val, txt) {
									$("#" + paramObj.forItem).val(txt);
								},
								readonly : (mode == "view" || paramObj.readOnly == true)
							}
						};

						this.assemblingItemPlug(selector, paramObj);

						if (vlu != null) {
							selector.options.initValue = vlu;
						} else if (paramObj.checkItem != null) {
							selector.options.initValue = paramObj.checkItem;
						}

						fields.push(selector);
					}
				} else {
					var ipt = {
						display : component.label,
						name : component.formName,
						id : component.formName,
						newline : newline,
						options : {
							value : component.defaultValue,
							disabled : (mode == "view" || paramObj.readOnly == true)
						},
						type : "checkbox"
					}

					this.assemblingItemPlug(ipt, paramObj);

					fields.push(ipt);
				}
			} else if (component.type == "radio") {
				if (paramObj != null && paramObj.items != null) {
					if ((mode == "view" || paramObj.readOnly == true)) {
						var ipt = {
							display : component.label,
							name : component.formName,
							id : component.formName,
							newline : newline,
							type : "text",
							options : {
								value : (vlu == null
										? component.defaultValue
										: vlu),
								readonly : (mode == "view" || paramObj.readOnly == true)
							}
						}

						this.assemblingItemPlug(ipt, paramObj);

						fields.push(ipt);
					} else {
						var values = paramObj.items;
						var dataGrid = [];

						for (var i = 0; i < values.length; i++) {
							var dataObj = {};
							dataObj["id"] = values[i].id;
							dataObj[component.formName + "_name"] = values[i].name;
							dataGrid.push(dataObj);

						}

						var selector = {
							display : component.label,
							name : component.formName,
							id : component.formName,
							type : "select",
							comboboxName : (component.formName + "_name"),
							newline : newline,

							options : {
								valueField : "id",
								textField : (component.formName + "_name"),
								data : dataGrid,
								valueFieldID : paramObj.forItem,
								onSelected : function(val, txt) {
									$("#" + paramObj.forItem).val(txt);
								},
								readonly : (mode == "view" || paramObj.readOnly == true)
							}
						};

						this.assemblingItemPlug(selector, paramObj);

						if (vlu != null) {
							selector.options.initValue = vlu;
						} else if (paramObj.checkItem != null) {
							selector.options.initValue = paramObj.checkItem;
						}

						fields.push(selector);
					}
				} else {
					var ipt = {
						display : component.label,
						name : component.formName,
						id : component.formName,
						options : {
							value : component.defaultValue,
							disabled : (mode == "view" || paramObj.readOnly == true)
						},
						newline : newline,
						type : "radio"
					}

					this.assemblingItemPlug(ipt, paramObj);

					fields.push(ipt);
				}
			} else if (component.type == "file") {
				if ((mode == "view" || paramObj.readOnly == true)) {
					if (vlu != null) {
						$.each(vlu, function(i, file) {
									var fileId = file.id;
									var fileType = file.type;
									var fileName = file.name + "." + fileType;

									var ipt = {
										display : component.label,
										name : component.formName,
										id : component.formName,
										newline : true,
										type : "text",
										options : {
											value : fileName,
											readonly : true,
											title : "点击下载查看文件-> " + fileName
													+ "",
											onClick : function() {
												if (file.type == "do") {
													downloadAnnex(fileId);
												} else {
													viewAnnex(fileName, fileId);
												}
											}
										}
									}

									// this.assemblingItemPlug(ipt, paramObj);

									if (paramObj.width != null) {
										ipt.width = paramObj.width;
									}

									if (paramObj.group != null) {
										ipt.group = paramObj.group;
									}

									if (paramObj.groupicon != null) {
										ipt.groupicon = paramObj.groupicon;
									}

									fields.push(ipt);
								});
					}
				} else {
					var ipt = {
						display : component.label,
						name : component.formName,
						id : component.formName,
						newline : newline,
						type : "file"
					}

					this.assemblingItemPlug(ipt, paramObj);

					fields.push(ipt);
				}
			} else if (component.type == "tablequery") {
				var grooveComboboxOptions = {
					queryKey : paramObj.queryKey,
					pageSize : paramObj.pageSize
				}

				if (paramObj.params != null) {
					grooveComboboxOptions.params = {};
					for (var property in paramObj.params) {
						var val = paramObj.params[property];

						if (typeof(val) != "function") {
							if ($.trim(val) != "" && val.substring(0, 1) == "@") {
								try {
									grooveComboboxOptions.params[property] = param2json(val
											.substring(1));
								} catch (e) {
									alert("item[" + component.name
											+ "][itablequery][param:"
											+ property + "] is invalid." + e);
								}
							} else {
								grooveComboboxOptions.params[property] = val;
							}
						}
					}
				}

				var gridOptions = new $.grooveComboboxQuery(grooveComboboxOptions);

				gridOptions.switchPageSizeApplyComboBox = true;

				if (paramObj.valueField == null) {
					alert(component.name + "(valueField) is necessary");
				}

				if (paramObj.textField == null) {
					alert(component.name + "(textField) is necessary");
				}

				/*
				 * p.onSelect({ value: value.join(p.split), text:
				 * text.join(p.split), data: data, remvoeValue:
				 * removeValue.join(p.split), remvoeText:
				 * removeText.join(p.split), removeData : removeData });
				 */

				var popupOptions = {
					slide : false,
					valueField : paramObj.valueField,
					textField : paramObj.textField,
					onSelected : function(val, txt) {
						if (paramObj.forItem != null) {
							$("#" + paramObj.forItem).val(val);
						}
						$("#" + component.formName).val(txt);
					},
					grid : gridOptions,
					condition : gridOptions.conditions
				}

				if (paramObj.width != null) {
					popupOptions.width = paramObj.width;
				} else {
					paramObj.width = 560;
					popupOptions.width = 560;
				}

				if (paramObj.boxWidth != null) {
					popupOptions.selectBoxWidth = paramObj.boxWidth;
				} else {
					popupOptions.selectBoxWidth = 600;
				}

				if (paramObj.boxHeight != null) {
					popupOptions.selectBoxHeight = paramObj.boxHeight;
				} else {
					popupOptions.selectBoxHeight = 300;
				}

				var ipt = {
					name : component.formName,
					id : component.formName,
					value : (vlu == null ? component.defaultValue : vlu),
					type : "popup",
					label : component.label,
					options : popupOptions
				}

				this.assemblingItemPlug(ipt, paramObj);

				fields.push(ipt);
			}

		},
		assemblingItem4List : function(component, vlu, validators) {
			var paramObj = eval(component.param);
			var ipt;
			// push validator component
			if (paramObj.validate != null) {
				validators.push(component.formName);
			}

			if (component.type == "input") {
				ipt = {
					type : "text",
					options : {
						number : paramObj.number == true,
						digits : paramObj.digits == true,
						currency : paramObj.currency == true
					}
				}

				this.assemblingItemPlug(ipt, paramObj);
			} else if (component.type == "textarea") {
				ipt = {
					type : "textarea"
				}

				this.assemblingItemPlug(ipt, paramObj);
			} else if (component.type == "date") {
				ipt = {
					type : "date"
				}

			} else if (component.type == "time") {
				ipt = {
					options : {
						showTime : true
					},
					type : "date"
				}

			} else if (component.type == "select"
					|| component.type == "combobox") {

				var values = paramObj.items;
				var dataGrid = [];

				for (var i = 0; i < values.length; i++) {
					var dataObj = {};
					dataObj[paramObj.forItem] = values[i].id;
					dataObj[component.formName] = values[i].name;
					dataGrid.push(dataObj);

				}

				ipt = {
					type : "select",

					options : {
						valueField : paramObj.forItem,
						textField : component.formName,
						data : dataGrid
					}
				};
			} else if (component.type == "checkbox") {
				if (paramObj != null && paramObj.items != null) {
					var values = paramObj.items;
					var dataGrid = [];

					for (var i = 0; i < values.length; i++) {
						var dataObj = {};
						dataObj[paramObj.forItem] = values[i].id;
						dataObj[component.formName] = values[i].name;
						dataGrid.push(dataObj);

					}

					ipt = {
						type : "select",
						options : {
							split : ",",
							isMultiSelect : true, // 是否多选
							isShowCheckBox : true, // 是否选择复选框
							valueField : paramObj.forItem,
							textField : component.formName,
							data : dataGrid
						}
					};
				} else {
					ipt = {
						type : "checkbox"
					}
				}
			} else if (component.type == "radio") {
				if (paramObj != null && paramObj.items != null) {
					var values = paramObj.items;
					var dataGrid = [];

					for (var i = 0; i < values.length; i++) {
						var dataObj = {};
						dataObj[paramObj.forItem] = values[i].id;
						dataObj[component.formName] = values[i].name;
						dataGrid.push(dataObj);

					}

					ipt = {
						type : "select",
						options : {
							valueField : paramObj.forItem,
							textField : component.formName,
							data : dataGrid
						}
					};
				} else {
					ipt = {
						type : "radio"
					}
				}
			} else if (component.type == "file") {
				ipt = {
					type : "file"
				}
			}

			return ipt;
		},
		assemblingList : function(jform, validators, viewConfig) {
			if (viewConfig.componentInList != null) {
				$.each(viewConfig.componentInList, function(i, n) {
					// get list grid
					var grid = viewConfig[n.id + "_grid"];
					// get grid data
					var data = grid.getData();
					if (data != null && data.length > 0) {
						var counter = "";
						// list grid data
						$.each(data, function(j, m) {
							if (j < data.length - 1) {
								counter += j + ",";
							} else {
								counter += j;
							}
							// alert(JSON.stringify(m));
							// list item in list
							$.each(n.items, function(k, item) {
								var val = m[item.formName];
								if (val) {
									var hidden = $("<input type=\"hidden\" name=\""
											+ item.formName
											+ "_"
											+ j
											+ "\" value=\"" + val + "\">");
									hidden.appendTo(jform);
								}

							});
						});

						var hid = $("<input type=\"hidden\" name=\""
								+ n.counterName + "\" value=\"" + counter
								+ "\">");
						hid.appendTo(jform);
						/*
						 * n.forTable n.counterName
						 */
					}

				});
			}
		}
	}

	/**
	 * for edit id 主键 tableName 表名称 viewId 视图id selfFunc 视图初始化
	 */
	$.grooveViewPre = function(id, tableName, viewId, selfFunc) {

		$.ajax({
					type : 'post',
					url : context + '/system/baseworkselect.do',
					data : {
						id : id,
						tableName : tableName
					},// 可以直接加一个函数名。
					dataType : 'json',
					async : false,
					success : function(data) {
						if (viewId != null) {
							var gv = new $.grooveView(viewId, selfFunc,
									(data.success ? data.data : {}));
						}
					}
				});
	}

	/**
	 * for edit jsonparams 数据选择参数 viewId 视图id selfFunc 视图初始化
	 * 
	 * jsonparams ： { id : "01", primaryTable : "primaryTest", foreignTables : [
	 * {foreignTable : "foreignTest1", orderby : "columnTest1", sort : "ASC" },{
	 * foreignTable : "foreignTest2", orderby : "columnTest2", sort : "DESC" }] }
	 * 
	 */
	$.grooveViewPreII = function(params, viewId, selfFunc) {

		$.ajax({
					type : 'post',
					url : context + '/system/baseworkselectII.do',
					data : {
						jsonparams : JSON.stringify(params)
					},// 可以直接加一个函数名。
					dataType : 'json',
					async : false,
					success : function(data) {
						if (data.success == false) {
							alert(data.errorMsg);
						} else {
							var view = new $.grooveView(viewId, selfFunc,
									(data.success ? data.resultData : {}));
						}
					},
					error : function(XMLHttpRequest, textStatus, errorThrown) {
						alert(XMLHttpRequest)
					}
				});
	}

	/* for add */
	$.grooveView = function(viewId, selfFunc, dataBean) {
		if (selfFunc == null) {
			selfFunc = {};
		}

		/* 请求参数,可携带表单默认值 */
		var requestData = null;

		if (selfFunc.params != null) {
			requestData = selfFunc.params;
		} else {
			requestData = {};
		}

		requestData.sessionUserId = userId;
		requestData.sessionUserName = userName;
		requestData.sessionGroupId = groupId;
		requestData.sessionGroupName = groupName;

		requestData.id = viewId;

		if (tableviewStuff[viewId] == null) {
			alert("获取" + viewId + "的命名空间失败");
		}

		$.ajax({
			type : "post",
			url : context + "/temp-store/jsstuff/tableview/"
					+ tableviewStuff[viewId] + "/" + viewId + ".json",
			data : requestData,// 可以直接加一个函数名。
			dataType : 'json',
			async : false,
			beforeSend : function() {
				/*
				 * $("body") .prepend("<div id=\"dialogValidateTips\"
				 * title=\"页面初始化错误信息\"></div>");
				 */

				if (selfFunc.beforecall != null) {
					selfFunc.beforecall.apply();
				}
			},
			success : function(data) {
				if (data.success == false) {
					if (data.errorMsg == "-1") {
						alert("未找到视图定义<" + viewId + ">");
					} else if (data.errorMsg == "-2") {
						alert("没有使用视图的权限");
					}
				} else {
					var validateTxt = '';
					if (selfFunc.formID == null) {
						alert("未定义参数'formID'");
					}

					if (selfFunc.submitButtonID == null) {
						// alert("未定义参数'submitButtonID'");
					}

					var tableNames = data.primaryTable;
					var counterNames = data.primaryTableCounterName;
					var handleTypes = data.primaryTableHandleType;
					var viewListener = data.listener;

					// data.primaryTableColumnFormName
					var fields = [];
					var validators = [];

					fields.push({
								name : data.primaryTableColumnFormName,
								type : "hidden",
								options : {
									value : (dataBean != null
											? dataBean[data.primaryTableColumn]
											: null)
								},
								id : data.primaryTableColumnFormName
							});

					fields.push({
								name : "listener",
								type : "hidden",
								options : {
									value : viewListener
								},
								id : "listener"
							});

					if (data.foreignTables != null) {
						$.each(data.foreignTables, function(i, n) {
									tableNames += "," + n.foreignTable;
									counterNames += ","
											+ n.foreignTableCounterName;
									handleTypes += ","
											+ n.foreignTableHandleType;
								});
					}

					fields.push({
								name : "tableNames",
								type : "hidden",
								options : {
									value : tableNames
								},
								id : "tableNames"
							});

					fields.push({
								name : "counterNames",
								type : "hidden",
								options : {
									value : counterNames
								},
								id : "counterNames"
							});

					fields.push({
								name : "handleTypes",
								type : "hidden",
								options : {
									value : handleTypes
								},
								id : "handleTypes"
							});

					/* init component */
					if (data.component != null) {

						$.each(data.component, function(i, n) {
									// 处理默认值
																	
									if (n.defaultValue != "") {
										var dv = methods.getDefaultValue(
												n.defaultValue, requestData);

										n.defaultValue = dv;
									}

									methods.assemblingItem(fields, n,
											(dataBean != null
													? dataBean[n.name]
													: null), validators,
											data.handlemode);
								});

						// 创建表单结构
					}

					$.metadata.setType("attr", "validate");
					var validator = $("#" + selfFunc.formID).validate({
						// 调试状态，不会提交数据的
						debug : false,
						errorPlacement : function(lable, element) {

							if (element.hasClass("l-textarea")) {
								element.addClass("l-textarea-invalid");
							} else if (element.hasClass("l-text-field")) {
								element.parent().addClass("l-text-invalid");
							}

							/*
							 * var nextCell = element.parents("td:first")
							 * .next("td");
							 * nextCell.find("div.l-exclamation").remove(); $('<div
							 * class="l-exclamation" title="' + lable.html() +
							 * '"></div>') .appendTo(nextCell).ligerTip();
							 */
						},
						success : function(lable) {
							var element = $("#" + lable.attr("for"));
							var nextCell = element.parents("td:first")
									.next("td");
							if (element.hasClass("l-textarea")) {
								element.removeClass("l-textarea-invalid");
							} else if (element.hasClass("l-text-field")) {
								element.parent().removeClass("l-text-invalid");
							}
							nextCell.find("div.l-exclamation").remove();
						}
					});

					$("#" + selfFunc.formID).ligerForm({
								inputWidth : 200,
								labelWidth : 120,
								space : 40,
								fields : fields
							});

					/* init list */
					if (data.componentInList != null) {
						$.each(data.componentInList, function(i, n) {
							$('<div class="l-group" style="width: '
									+ ($("#" + selfFunc.formID).width() * 0.95)
									+ 'px;"><span style="width:100%">'
									+ n.param.title
									+ '</span><div class="togglebtn"></div></div><div id="'
									+ n.id + '"></div>').appendTo($("#"
									+ selfFunc.formID));
							var columns = [];
							$.each(n.items, function(j, m) {
								var col = {
									display : m.label,
									name : m.formName,
									align : m.align,
									hide : (m.type == "hidden"),
									width : (isNaN(parseInt(m.width))
											? 100
											: parseInt(m.width)),
									isSort : true,
									isAllowHide : true
								}

								if (m.type != "hidden") {
									var editor = methods.assemblingItem4List(m);

									if (editor != null) {
										col.editor = editor;
									}
								}

								col.render = function(rowdata, rowindex, value,
										column) {
									return listInViewFnRender(rowdata,
											rowindex, value, column, n.id,
											m.type);
								};

								columns.push(col);
							});

							var gridOptions = {
								checkbox : (data.handlemode != "view"),
								columns : columns,
								enabledEdit : (data.handlemode != "view"),
								isScroll : true,
								width : ($("#" + selfFunc.formID).width()
										* 0.95 - 1),
								height : n.param.height,
								usePager : false

							};

							if (data.handlemode != "view") {
								var toolbar = {
									items : [{
										text : '增加',
										click : function() {
											var manager = $("#" + n.id)
													.ligerGetGridManager();
											var s = manager.addRow();
										},
										icon : 'add'
									}, {
										line : true
									}, {
										text : '删除',
										click : function() {
											var ligerGrid = $("#" + n.id)
													.ligerGetGridManager();
											var records = ligerGrid.selected;
											if (records.length > 0) {
												var params = {}

												var counter1 = "";

												$.each(records, function(i,
														rowData) {
													if (rowData[n.forTablePrimaryColumnFormName] != null
															&& rowData[n.forTablePrimaryColumnFormName] != "") {

														// count true data
														// in list
														if (i < records.length
																- 1) {
															counter1 += i + ",";
														} else {
															counter1 += i;
														}

														$.each(n.items,
																function(j, m) {
																	params[m.formName
																			+ "_"
																			+ i] = rowData[m.formName];
																});
													}
												});
												// delete true data in list
												if (counter1 != "") {
													params.counter1 = counter1;

													grooveDeleteSubmit(
															n.forTable,
															"counter1",
															"multi", null,
															params, function() {
																return true;
															}, function() {
																ligerGrid
																		.deleteSelectedRow();
															});
												} else {
													ligerGrid
															.deleteSelectedRow();
												}
											} else {
												$.ligerDialog.warn("请选择要删除的数据");
											}
										},
										icon : 'delete'
									}]
								}

								gridOptions.toolbar = toolbar;
							}

							// init grid data
							if (dataBean != null && dataBean[n.id] != null
									&& dataBean[n.id].length > 0) {
								var gridData = {
									Rows : [],
									Total : dataBean[n.id].length
								};

								$.each(dataBean[n.id], function(k, da) {
									var rowData = {}

									$.each(n.items, function(j, m) {
												rowData[m.formName] = da[m.name];
											});

									gridData.Rows.push(rowData);
								});

								gridOptions.data = gridData;
							}

							var listGrid = $("#" + n.id).ligerGrid(gridOptions);

							data[n.id + "_grid"] = listGrid;
						});
					}

					if (validateTxt != '') {
						// show error msg
					}
					var tip;

					$("#" + selfFunc.submitButtonID).bind('click', function() {
						var submitMe = true;
						for (var i = 0; i < validators.length; i++) {
							if (!validator.element($("#" + validators[i]))) {
								submitMe = false;
								break;
							}
						}
						if (!submitMe) {
							alert("请正确填写或选择数据");
							// $.ligerDialog.warn("请正确填写或选择数据");
						} else {

							$.ligerDialog.confirm(
									(selfFunc.submitMessage == null
											? "确定提交保存数据"
											: selfFunc.submitMessage),
									function(yes) {
										if (yes) {
											methods.assemblingList($("#"
															+ selfFunc.formID),
													validators, data);

											var options = {
												beforeSubmit : function(
														formData, jqForm,
														options) {
													$.ligerDialog
															.waitting('数据提交处理过程中...');
													return true;
												},
												success : function showResponse(
														responseText,
														statusText) {
													// clear list
													if (selfFunc.mode == "insert") {
														if (data.componentInList != null) {
															$
																	.each(
																			data.componentInList,
																			function(
																					i,
																					n) {
																				var manager = $("#"
																						+ n.id)
																						.ligerGetGridManager();
																				manager
																						.reload();
																			});
														}
													}

													$.ligerDialog
															.closeWaitting();

													var json = param2json(responseText);

													if (!json.success) {
														$.ligerDialog
																.error(json.msg);
													}

													if (selfFunc.aftercall != null) {
														selfFunc.aftercall(
																responseText,
																statusText,
																selfFunc);
													} else {

														if (json.success) {
															/*
															 * alert(selfFunc.OKMessage !=
															 * null ?
															 * selfFunc.OKMessage :
															 * json.msg);
															 */

															$.ligerDialog
																	.success(selfFunc.OKMessage != null
																			? selfFunc.OKMessage
																			: json.msg);
														}
													}
												},
												error : function(
														XMLHttpRequest,
														textStatus, errorThrown) {
													$.ligerDialog
															.closeWaitting();
												},
												url : context
														+ "/system/baseworkremix.do", // override
												// contentType :
												// "application/json",
												type : "post",
												resetForm : (selfFunc.mode == "insert"),
												iframe : ($("#"
														+ selfFunc.formID)
														.attr("enctype") == "multipart/form-data")
											};

											$("#" + selfFunc.formID)
													.ajaxSubmit(options);
										}
									});
						}
					});

					if (selfFunc.rendercall != null) {
						selfFunc.rendercall(selfFunc, validator, validators,
								data, dataBean);
					}
				}
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
				alert(XMLHttpRequest.responseText);
			}
		});
	};

	/* for delete */
	$.grooveDelete = function(param, selfFunc) {
		if (selfFunc == null) {
			selfFunc = {};
		}

		if ($("#dialogDelSubmitTips").length == 0) {
			$("<div>", {
						id : "dialogDelSubmitTips",
						title : "提交确认窗口"
					}).append("<p>"
					+ (selfFunc.submitMessage == null
							? "您确定要删除当前信息?"
							: selfFunc.submitMessage) + "</p>")
					.appendTo("body");

			$("#dialogDelSubmitTips").dialog({
						autoOpen : true,
						width : 400,
						height : 200,
						modal : true,
						closeOnEscape : true,
						resizable : false,
						// hide : "explode",
						// show : "slow",
						buttons : [{
									id : "dialogDelSubmitButton",
									text : " 确定 ",
									click : function() {

									}
								}, {
									text : " 取消 ",
									click : function() {
										$(this).dialog("close");
									}
								}]
					});
		} else {
			$("#dialogDelSubmitTips").dialog("open");
		}

		$("#dialogDelSubmitButton").bind("click", function() {
					$("#dialogDelSubmitTips").dialog("close");

					$.ajax({
								type : "POST",
								url : context + "/system/baseworkdelete.do",
								data : param,
								success : function(resultData) {
									if (resultData.success) {
										if (selfFunc.aftercall != null) {
											selfFunc.aftercall
													.apply(resultData);
										}
									} else {
										alert("删除操作出现异常," + resultData.errorMsg);
									}
								}
							});
				});

		$("#dialogDelSubmitButton").unbind('click');
	}

	/* for delete II */
	$.grooveDeleteII = function(param, selfFunc) {
		if (selfFunc == null) {
			selfFunc = {};
		}

		if ($("#dialogDelIISubmitTips").length == 0) {
			$("<div>", {
						id : "dialogDelIISubmitTips",
						title : "提交确认窗口"
					}).append("<p>"
					+ (selfFunc.submitMessage == null
							? "您确定要删除当前信息?"
							: selfFunc.submitMessage) + "</p>")
					.appendTo("body");

			$("#dialogDelIISubmitTips").dialog({
						autoOpen : true,
						width : 400,
						height : 200,
						modal : true,
						closeOnEscape : true,
						resizable : false,
						// hide : "explode",
						// show : "slow",
						buttons : [{
									id : "dialogDelIISubmitButton",
									text : " 确定 ",
									click : function() {

									}
								}, {
									text : " 取消 ",
									click : function() {
										$(this).dialog("close");
									}
								}]
					});
		} else {
			$("#dialogDelIISubmitTips").dialog("open");
		}

		$("#dialogDelIISubmitButton").bind("click", function() {
					$("#dialogDelIISubmitTips").dialog("close");
					$.ajax({
								type : "POST",
								url : context + "/system/baseworkdeleteII.do",
								data : param,
								success : function(resultData) {
									if (resultData.success) {
										if (selfFunc.aftercall != null) {
											selfFunc.aftercall
													.apply(resultData);
										}
									} else {
										alert("删除操作出现异常," + resultData.errorMsg);
									}
								}
							});
					$("#dialogDelIISubmitButton").unbind('click');
				});

	}

	var checkboxGroups = [];

	$.fn.checkBox = function(form) {
		$(checkboxGroups).each(function(j, m) {
			var ids = "";
			var names = "";
			form.find("input:checkbox[itemName='" + m.itemName + "']").each(
					function(i, n) {
						if ($(n).attr("checked")) {
							names += $(n).attr("label") + ",";
							ids += $(n).val() + ",";
						}
					});

			$("#" + m.itemName).attr("value", ids.substring(0, ids.length - 1));
			$("#" + m.forItem).attr("value",
					names.substring(0, names.length - 1));
		});
	}

	$.fn.assemblingItem4List = function(component, vlu) {
		var paramObj = eval(component.param);

		if (component.type == "input") {
			var ipt = $("<input>", {
						"type" : "text",
						"value" : (vlu == null ? component.defaultValue : vlu),
						"readonly" : paramObj.readOnly,
						"name" : component.formName,
						"id" : component.formName
					});
			if (paramObj.VEClassName != null
					&& $.trim(paramObj.VEClassName) != "") {
				ipt.addClass(paramObj.VEClassName);
			} else {
				ipt.addClass("text-input");
			}
			ipt.insertBefore($(this));
		} else if (component.type == "hidden") {
			$("<input>", {
						"type" : "hidden",
						"value" : vlu == null ? component.defaultValue : vlu,
						"name" : component.formName,
						"id" : component.formName
					}).insertBefore($(this));
		} else if (component.type == "textarea") {
			var txt = $("<textarea>", {
						"value" : (vlu == null ? component.defaultValue : vlu),
						"name" : component.formName,
						"id" : component.formName
					});
			if (paramObj.VEClassName != null
					&& $.trim(paramObj.VEClassName) != "") {
				txt.addClass(paramObj.VEClassName);
			} else {
				txt.addClass("text-input");
			}
			txt.insertBefore($(this));
		} else if (component.type == "date") {
			var ipt = $("<input>", {
						"type" : "text",
						"value" : (vlu == null
								? component.defaultValue
								: methods.parseDate(vlu)),
						"name" : component.formName + "_",
						"id" : component.formName + "_"
					})

			ipt.change(function() {
						// alert($(this).val());
						$("#" + component.formName).val(methods.formatTime(
								$(this).val(), "000000"));
					});

			if (paramObj.VEClassName != null
					&& $.trim(paramObj.VEClassName) != "") {
				ipt.addClass(paramObj.VEClassName);
			} else {
				ipt.addClass("validate[custom[date]] text-input datepicker");
			}

			ipt.insertBefore($(this));

			$("<input>", {
						"type" : "hidden",
						"value" : (vlu == null ? component.defaultValue : vlu),
						"name" : component.formName,
						"id" : component.formName
					}).insertBefore($(this));

			ipt.datepicker({
						// changeMonth : true,
						// changeYear : true,
						altField : "#" + component.formName,
						showWeek : true,
						regional : "zh-CN",
						showButtonPanel : true,
						dateFormat : "yy-mm-dd"
					});
		} else if (component.type == "select") {
			var selector = $("<select>", {
						"name" : component.formName,
						"id" : component.formName
					});
			// var selector = $('<select></select>');
			selector.bind("change", function() {
				// alert($(this).val() + "<--->" + $(this).text());
				$("#" + paramObj.forItem).attr("value", $(this).text());
					// $(this).children("option:selected").val()
				})
			var values = paramObj.items;

			for (var i = 0; i < values.length; i++) {
				selector.append("<option value=\"" + values[i].id + "\">"
						+ values[i].name + "</option>");
			}

			if (paramObj.VEClassName != null
					&& $.trim(paramObj.VEClassName) != "") {
				selector.addClass(paramObj.VEClassName);
			} else {
				selector.addClass("select");
			}

			selector.insertBefore($(this));
		} else if (component.type == "combobox") {

		} else if (component.type == "checkbox") {
			if (paramObj != null && paramObj.items != null) {
				var values = paramObj.items;
				for (var i = 0; i < values.length; i++) {
					var chk = $("<input>", {
								"type" : "checkbox",
								"value" : values[i].id,
								"name" : component.formName + "_",
								"label" : values[i].name,
								"checked" : (methods
										.checkItemInGroup((vlu == null
														? paramObj.checkItem
														: vlu), values[i].id)
										? true
										: false),
								"id" : component.formName + "_idx_" + i
							});

					chk.click(function() {
								var chked = $("input[type=checkbox][name="
										+ component.formName + "_][checked]");
								var ids = "";
								var names = "";
								for (var i = 0; i < chked.length; i++) {
									if (i < chked.length - 1) {
										ids += chked[i].val() + ",";
										names += chked[i].attr("label") + ",";
									} else {
										ids += chked[i].val();
										names += chked[i].attr("label");
									}
								}

								$("#" + component.formName).attr("value", ids);
								$("#" + component.formItem)
										.attr("value", names);
							});

					if (paramObj.VEClassName != null
							&& $.trim(paramObj.VEClassName) != "") {
						chk.addClass(paramObj.VEClassName);
					}

					chk.insertBefore($(this));

					$("<label for=\"" + (component.formName + "_idx_" + i)
							+ "\">" + values[i].name + "</label>")
							.insertBefore($(this));
				}

				$("<input>", {
							"type" : "hidden",
							"name" : component.formName,
							"id" : component.formName
						}).insertBefore($(this));
			} else {
				var chk = $("<input>", {
							"type" : "checkbox",
							"value" : component.defaultValue,
							"checked" : (vlu == null
									? component.defaultValue
									: vlu),
							"name" : component.formName,
							"label" : component.label,
							"id" : component.formName
						});

				chk.click(function() {
							if ($(this).attr("checked")
									&& $("#" + paramObj.forItem).length > 0) {
								$("#" + paramObj.forItem).val($(this)
										.attr("label"));
							} else {
								$("#" + paramObj.forItem).val("");
							}
						});

				if (paramObj.VEClassName != null
						&& $.trim(paramObj.VEClassName) != "") {
					chk.addClass(paramObj.VEClassName);
				}

				chk.insertBefore($(this));

				$("<label for=\"" + (component.formName) + "\">"
						+ component.label + "</label>").insertBefore($(this));
			}
		} else if (component.type == "radio") {
			if (paramObj != null && paramObj.items != null) {
				var values = paramObj.items;

				for (var i = 0; i < values.length; i++) {
					var rad = $("<input>", {
						"type" : "radio",
						"value" : values[i].id,
						"name" : component.formName,
						"label" : values[i].name,
						"checked" : ((paramObj.checkItem == values[i].id || values[i].id == vlu)
								? true
								: false),
						"id" : component.formName + "_idx_" + i
					});

					rad.click(function() {
								if ($(this).attr("checked")
										&& $("#" + paramObj.forItem).length > 0) {
									$("#" + paramObj.forItem).val($(this)
											.attr("label"));
								}
							});

					if (paramObj.VEClassName != null
							&& $.trim(paramObj.VEClassName) != "") {
						rad.addClass(paramObj.VEClassName);
					}

					rad.insertBefore($(this));

					$("<label for=\"" + (component.formName + "_idx_" + i)
							+ "\">" + values[i].name + "</label>")
							.insertBefore($(this));
				}
			} else {
				var rad = $("<input>", {
					"type" : "radio",
					"value" : component.defaultValue,
					"checked" : ((paramObj.checkItem == component.defaultValue || component.defaultValue == vlu)
							? true
							: false),
					"name" : component.formName,
					"label" : component.label,
					"id" : component.formName
				});

				rad.click(function() {
							if ($(this).attr("checked")
									&& $("#" + paramObj.forItem).length > 0) {
								$("#" + paramObj.forItem).val($(this)
										.attr("label"));
							}
						});

				if (paramObj.VEClassName != null
						&& $.trim(paramObj.VEClassName) != "") {
					rad.addClass(paramObj.VEClassName);
				}

				rad.insertBefore($(this));

				$("<label for=\"" + (component.formName) + "\">"
						+ component.label + "</label>").insertBefore($(this));

			}
		} else if (component.type == "file") {
			var file = $("<input>", {
						"type" : "file",
						"name" : component.formName,
						"id" : component.formName
					});
			if (paramObj.VEClassName != null
					&& $.trim(paramObj.VEClassName) != "") {
				file.addClass(paramObj.VEClassName);
			}

			file.insertBefore($(this));
		}

		$(this).remove();
	};

	$.fn.analyzingItem4List = function(component, idx) {
		var cmpName;
		var cmpId;
		var cmpValue;
		var cmpLabel;

		if (component.type == "input" || component.type == "hidden"
				|| component.type == "textarea") {
			cmpName = component.formName + "_" + idx;
			cmpId = component.formName + "_" + idx;
			cmpValue = $("#" + component.formName).val();
			cmpLabel = $("#" + component.formName).val();
		} else if (component.type == "date") {
			cmpName = component.formName + "_" + idx;
			cmpId = component.formName + "_" + idx;
			cmpValue = methods.formatTime($("#" + component.formName + "_")
							.val(), "000000");
			cmpLabel = $("#" + component.formName + "_").val();
		} else if (component.type == "select") {
			cmpName = component.formName + "_" + idx;
			cmpId = component.formName + "_" + idx;
			cmpValue = $("#" + component.formName).val();
			cmpLabel = $("#" + component.formName).text();
		} else if (component.type == "combobox") {

		} else if (component.type == "checkbox") {
			if (paramObj != null && paramObj.items != null) {
				cmpName = component.formName + "_" + idx;
				cmpId = component.formName + "_" + idx;
				cmpValue = $("#" + component.formName).val();
				cmpLabel = $("#" + component.forItem).val();
			} else {
				cmpName = component.formName + "_" + idx;
				cmpId = component.formName + "_" + idx;
				cmpValue = $("#" + component.formName).val();
				cmpLabel = $("#" + component.formName).attr("label");
			}
		} else if (component.type == "radio") {
			cmpName = component.formName + "_" + idx;
			cmpId = component.formName + "_" + idx;
			cmpValue = $("#" + component.formName).val();
			cmpLabel = $("#" + component.formName).attr("label");
		} else if (component.type == "file") {

		}

		var ipt = $("<input>", {
					"type" : "hidden",
					"value" : cmpValue,
					"name" : cmpName,
					"id" : cmpId
				});

		$(this).append(ipt);

		$(this).append(cmpLabel);
	};

	/* 初始化信息定义窗口 */
	$.fn.initDialog4List = function(n) {
		var columns = [];

		if (n.items != null) {
			$.each(n.items, function(j, m) {
						var col = {
							display : m.display,
							name : m.name,
							align : m.align,
							hide : m.hide,
							width : parseInt(m.width),
							isSort : (m.alien != "1" && m.name != "PAGINATION_NUMBER"),
							isAllowHide : true
						}

						if (m.alien != "1" && m.name != "PAGINATION_NUMBER"
								&& m.hide == false) {

						}

						if (m.hide == false) {
							// col.render = eval(m.render);
							// col.headerRender = eval(m.headerRender);
						}

						columns.push(col);
					});
		}
	}

	/**
	 * 增加或重置列表行
	 */
	$.fn.setTableList = function(n) {
		var counter_ = parseInt($("#" + n.id).attr("counter_"));
		var tridx = $("#" + n.id).attr("nowEditIdx");

		/* 编辑操作 */
		if ($.trim(tridx) != "") {
			var trid = n.id + "_tr_" + tridx;
			var tbodytr = $("#" + trid);

			$.each(n.items, function(j, m) {
						if (m.type == "hidden") {
							$("#" + m.formName + "_" + tridx).attr("value",
									$("#" + m.formName).val());
						} else {
							var tdid = n.id + "_tr_" + tridx + "_td_"
									+ m.formName;

							var span = $("<span>");
							span.analyzingItem4List(m, tridx);

							var tbodytrtd = $("#" + tdid);
							tbodytrtd.html("");
							tbodytrtd.append(span);
						}
					});
		} else {
			/* 新定义操作 */
			var trid = n.id + "_tr_" + counter_;
			var idx = counter_;
			var tbodytr = $("<tr>", {
						"id" : trid
					});
			tbodytr.attr("idx", idx);
			$("#" + n.id + ">tbody").append(tbodytr);

			$.each(n.items, function(j, m) {
						if (m.type == "hidden") {
							tbodytr.append("<input>", {
										"type" : "hidden",
										"name" : m.formName + "_" + counter_,
										value : $("#" + m.formName).val()
									});
							$("#" + m.formName).attr("value", "");
						} else {
							var span = $("<span>");
							span.analyzingItem4List(m, counter_);
							var tdid = n.id + "_tr_" + counter_ + "_td_"
									+ m.formName;
							var tbodytrtd = $("<td>", {
										id : tdid,
										align : "center"
									});
							tbodytrtd.append(span);
							tbodytr.append(tbodytrtd);
							$("#" + m.formName).attr("value", "");
						}
					});

			var span = $("<span>");

			var editA = $("<a>");
			span.append(editA);
			editA.attr("href", "javascript:void(0);");
			editA.html("编辑");
			editA.bind("click", function() {
						/* 记录当前编辑行序列 */
						$("#" + n.id).attr("nowEditIdx", idx);
						$(this).initDialog4List(n);
					});
			span.append("&nbsp;");
			var eidtD = $("<a>");
			span.append(eidtD);
			eidtD.attr("href", "javascript:void(0);");
			eidtD.html("删除");
			eidtD.bind("click", function() {
						$(this).listCount(n);
						$("#" + trid).remove();
					});

			var tdid = n.id + "_tr_" + counter_ + "_td_AA";
			var tbodytrtd = $("<td>", {
						id : tdid,
						align : "center"
					});
			tbodytrtd.append(span);
			tbodytr.append(tbodytrtd);

			counter_++;

			$("#" + n.id).attr("counter_", counter_);

			$(this).listCount(n);
		}
	}

	$.fn.listCount = function(n) {
		var idxstr = "";
		$("#" + n.id + ">tbody").find("tr").each(function() {
					idxstr += $(this).attr("idx") + ",";
				});

		$("#" + n.counterName).attr("value", idxstr);
	}

	$.fn.removeReal = function(id, tableName) {

		return false;
	}

	$.fn.handleSubmit = function(selfFunc, validator, validators, viewConfig) {
		var submitMe = true;
		for (var i = 0; i < validators.length; i++) {
			if (!validator.element($("#" + validators[i]))) {
				submitMe = false;
				break;
			}
		}
		if (!submitMe) {
			alert("请正确填写或选择数据");
			// $.ligerDialog.warn("请正确填写或选择数据");
		} else {
			$.ligerDialog.confirm((selfFunc.submitMessage == null
							? "确定提交保存数据"
							: selfFunc.submitMessage), function(yes) {
						if (yes) {
							methods.assemblingList($("#" + selfFunc.formID),
									validators, viewConfig);

							var options = {
								beforeSubmit : function(formData, jqForm,
										options) {
									$.ligerDialog.waitting('数据提交处理过程中...');
									return true;
								},
								success : function showResponse(responseText,
										statusText) {
									$.ligerDialog.closeWaitting();
									var json = param2json(responseText);
									if (!json.success) {
										$.ligerDialog.error(json.msg);
									}

									if (selfFunc.aftercall != null) {
										selfFunc.aftercall(responseText,
												statusText);
									} else {
										if (json.success) {
											/*
											 * alert(selfFunc.OKMessage != null ?
											 * selfFunc.OKMessage : json.msg);
											 */

											$.ligerDialog
													.success(selfFunc.OKMessage != null
															? selfFunc.OKMessage
															: json.msg);
										}
									}
								},
								error : function(XMLHttpRequest, textStatus,
										errorThrown) {
									$.ligerDialog.closeWaitting();
								},
								url : context + "/system/baseworkremix.do", // override
								// contentType :
								// "application/json",
								type : "post",
								resetForm : (selfFunc.mode == "insert"),
								iframe : ($("#" + selfFunc.formID)
										.attr("enctype") == "multipart/form-data")
							};

							$("#" + selfFunc.formID).ajaxSubmit(options);
						}
					});
		}
	}
})(jQuery);

function listInViewFnRender(rowdata, rowindex, value, column, gridId, itemType) {
	if (itemType == "date") {
		return formatDate(value);
	} else if (column.name == "file") {
		return "file in list";
	}
	return value;
}